<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/layui/css/layui.css">
</head>
<body>
<div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <header style="height: 100%">
            <div align="left">
                <table style="width: 100%">
                    <tr>
                        <td>
                            <form class="form-inline" onsubmit="return false">
                                <div class="form-group">
                                    用户名:
                                    <input id="username" type="text" class="form-control" placeholder="用户名">
                                    昵称:
                                    <input id="nickname" type="text" class="form-control" placeholder="昵称">
                                    <button id="searchBt" class="layui-btn layui-btn-sm" permission="sys:user:query"><i
                                            class="layui-icon">&#xe615;</i>搜索
                                    </button>
                                </div>
                            </form>
                        </td>
                    </tr>
                </table>
            </div>
        </header>

        <div>
            <div class="widget-body no-padding">
                <table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
                    <thead>
                    <tr>
                    </tr>
                    <tr>
                        <th>会员号</th>
                                                <th>会员昵称</th>
                                                <th>手机号</th>
                                                <th>邮箱</th>
                                                <th>性别</th>
                                                <th>生日</th>
                                                <!--<th>证件类型</th>
                                                <th>证件号</th>
                                                <th>标签</th>-->
                                                <th>实名认证</th>
                                                <th>会员等级</th>
                                                <th>邀请人</th>
                                                <th>注册来源</th>
                                                <th>邀请码</th>
                                                <th>创建时间</th>
                                                <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript" src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../../global/js/my/permission.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<script type="text/javascript" src="../../global/js/dict.js"></script>
<script type="text/javascript">
    layui.use(['layer'], function () {
        var layer = layui.layer;
    });
    var example;

    function init() {
        example =
            $('#dt-table').DataTable({
                "searching": false,
                "processing": false,
                "serverSide": true,
                "language": {
                    "url": "/global/js/plugin/datatables/Chinese.lang"
                },
                "ajax": {
                    "url": "/clyjUser/clyjuserList",
                    "type": "get",
                    "data": function (d) {
                        d.username = $('#username').val();
                        d.nickname = $('#nickname').val();
                        d.status = $('#status').val();
                    },
                    "error": function (xhr, textStatus, errorThrown) {
                        var msg = xhr.responseText;
                        console.log(msg);
                        var response = JSON.parse(msg);
                        var code = response.code;
                        var message = response.message;
                        if (code == 400) {
                            layer.msg(message);
                        } else if (code == 401) {
                            localStorage.removeItem("token");
                            layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function () {
                                location.href = '/login.html';
                            });
                        } else if (code == 403) {
                            console.log("未授权:" + message);
                            layer.msg('未授权');
                        } else if (code == 500) {
                            layer.msg('系统错误:' + message);
                        }
                    }
                },
                "dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
                "columns": [
                                        {"data": "memberId", "defaultContent": ""},
                                        {"data": "username", "defaultContent": ""},
                                        {"data": "phone", "defaultContent": ""},
                                        {"data": "email", "defaultContent": ""},
                                        {"data": "sex", "defaultContent": "",
                                        "render": function (data, type, row) {
                                              console.log(data)
                                              if (data == 0) {
                                                  data = "男"
                                          } else if (data == 1) {
                                                 data = "女"}
                                                   return data;}},
                                        {"data": "birthday", "defaultContent": ""},
                                       /* {"data": "identityType", "defaultContent": "",
                                        "render": function (data, type, row) {
                                               console.log(data)
                                                 if (data == 0) {
                                                data = "身份证"
                                                 } else if (data == 2) {
                                                 data = "护照"}
                                                  return data;}},
                                        {"data": "idCardNo", "defaultContent": ""},
                                        {"data": "tags", "defaultContent": ""},*/
                                        {"data": "isAttestation", "defaultContent": "",
                                        "render": function (data, type, row) {
                                                  console.log(data)
                                                  if (data == 0) {
                                                  data = "否"
                                                  } else if (data == 2) {
                                                  data = "是"}
                                                  return data;}},
                                        {"data": "level", "defaultContent": "",
                                        "render": function (data, type, row) {
                                                  console.log(data)
                                                   if (data == 0) {
                                                   data = "普通会员"
                                                   } else if (data == 1) {data = "导师"}
                                                   else if (data == 2){data = "讲师"}
                                                   else if (data == 3){data = "经理"}
                                                    return data;}},
                                        {"data": "inviter", "defaultContent": ""},
                                        {"data": "registSource", "defaultContent": ""},
                                        {"data": "inviteCode", "defaultContent": ""},
                                        {"data": "createTime", "defaultContent": "",
                                         "render":function(data) {
                                                                if(data==null || data==""){
                                                                    return data;
                                                                }
                                                              var dateee = new Date(data).toJSON();
                                                              var date=new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
                                                              data=date
                                                              return data;
                                                            }},
                    {
                        "data": "",
                        "defaultContent": "",
                        "orderable": false,
                        "render": function (data, type, row) {
						var id = row['userId'];
                        var href = "updateUser.html?id=" + id;
                        var btn = $("<button class='layui-btn layui-btn-xs' title='编辑' onclick='window.location=\"" + href + "\"'><i class='layui-icon'>&#xe642;</i></button>");
                        return btn.prop("outerHTML");
                        }
                    },

                ],
                "order": [[0, "desc"], [1, "asc"]]
            });
    }

    $("#searchBt").click(function () {
        example.ajax.reload();
    });

    init();
</script>